
const map = Object.assign({},  
  require('./data.js'), 
  require('./mock.js'), 
);
function send(res,data){
	res.setHeader("Access-Control-Allow-Origin", "*");
	res.setHeader("Access-Control-Allow-Headers", "Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild");
	res.setHeader("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
	res.setHeader("X-Powered-By","3.2.1");
	res.setHeader("Content-Type", "application/json;charset=utf-8");

	res.writeHead(200, {'Content-Type': 'application/json;charset=utf-8'});
	res.end(JSON.stringify(data));
}

const http = require('http');
const url = require("url");
http.createServer((req,res)=>{
    var parms = url.parse(req.url,true);
	console.log(1,req.url);
	send(res,map[parms.pathname]||  { url:req.url,"code": "", "data": {}, "msg": "", "success": true });	
}).listen(9000, '127.0.0.1', () => {
    console.log(`Server is running.... / on 9000 `); 
});
